<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>页面1</title>
  <!--<script src="../../static/js/vue.global.js"></script>-->
  <script src="../../static/js/vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>页面1</h1>
    <div><button @click="open">打开页面2</button></div>
    <p>希望传给页面2的信息：<input type="text" v-model="msg"></p>
    <div><button @click="send">发送</button></div>
  </div>
  <script>
    let openWindow = null;
    var vm = new Vue({
      el: '#app',
      data() {
        return {
          msg: '',
        }
      },
      methods: {
        open() {
          openWindow = window.open('http://127.0.0.1:57111/2.html')
        },
        send() {
          openWindow.postMessage({
            type: 'type1',
            message: this.msg
          }, 'http://127.0.0.1:57111/')
        }
      }
    })
  </script>
</body>
</html>
